package pipe.reader.writer;

import pipe.reader.writer.thread.ThreadReader;
import pipe.reader.writer.thread.ThreadWriter;

import java.io.IOException;
import java.io.PipedReader;
import java.io.PipedWriter;

public class Run {
    public static void main(String[] args) {
        try{
            WriteData writeData = new WriteData();
            ReadData readData =new ReadData();
            PipedReader reader= new PipedReader();
            PipedWriter writer =new PipedWriter();

            writer.connect(reader);
            ThreadReader threadReader = new ThreadReader(readData,reader);
            threadReader.start();

            Thread.sleep(2000);

            ThreadWriter threadWriter = new ThreadWriter(writeData,writer);
            threadWriter.start();
        }catch (IOException e) {
            e.printStackTrace();
        }catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
